//216组合总和 https://leetcode-cn.com/problems/combination-sum-iii/
class Solution {
public:
    void backtracking(int n,int k,int startindex,int sum)
    {
        if(temp.size() == k && sum == n)
        {
            result.push_back(temp);
            return;
        }
        if(temp.size()> k || sum > n)
        {
            return;
        }
        for(int i = startindex;i <= 9 ;i++)
        {
            temp.push_back(i);
            sum+=i;
            backtracking(n,k,i+1,sum);
            sum-=i;
            temp.pop_back();
        }
    }
    vector<vector<int>> result;
    vector<int> temp;
    vector<vector<int>> combinationSum3(int k, int n) {
        backtracking(n,k,1,0);
        return result;
    }
};